/*******************************************************************
 *
 * Copyright (C), 2021-2022, LS, All rights reserved.
 *
 * Author      : 
 * Create Time : 2021-09-17
 * Version     : v0.1
 * Description : 
 *******************************************************************/

#ifndef _LS_BLE_PHY62XX_H_
#define _LS_BLE_PHY62XX_H_

/*----------------------------Head file----------------------------*/
#include "stdint.h"
#include "stdbool.h"

/*----------------------------macro file---------------------------*/
#define ADV_DATA_NO_DEV_NAME_LEN    9
#define ADV_DATA_MAX_LEN            31

/*----------------------------type define--------------------------*/
#pragma pack(1)
typedef struct {
    uint8_t len;
    uint8_t  value[ADV_DATA_MAX_LEN];
} ls_ble_data_t;

typedef struct {
    double  adv_interval_min; //ms
    double  adv_interval_max; //ms
    uint8_t adv_type;
    uint8_t adv_power;
    uint8_t adv_channal_map;
} ls_ble_adv_param_t;

typedef struct {
    uint8_t type;
    uint8_t addr[6];
} ls_ble_mac_t;
#pragma pack()

/*----------------------------var define---------------------------*/							

/*-------------------------func declaration------------------------*/
extern uint16_t ls_ble_init(void);
extern uint16_t ls_ble_start_adv(void);
extern uint16_t ls_ble_stop_adv(void);
extern uint16_t ls_ble_disconnect(void);
extern uint16_t ls_ble_set_mac(const ls_ble_mac_t* p_mac);
extern uint16_t ls_ble_get_mac(ls_ble_mac_t* p_mac);
extern uint16_t ls_ble_set_device_name(const uint8_t* buf, uint16_t size);
extern uint16_t ls_ble_get_device_name(uint8_t* buf, uint16_t* p_size);
extern uint16_t ls_ble_set_advdata(const ls_ble_data_t* p_adv_data);
extern uint16_t ls_ble_set_scanrsp(const ls_ble_data_t* p_scan_rsp);
extern uint16_t ls_ble_set_adv_param(const ls_ble_adv_param_t* p_param);
extern uint16_t ls_ble_set_conn_param(uint16_t cMin, uint16_t cMax, uint16_t latency, uint16_t timeout);
extern uint16_t ls_ble_set_local_name(uint8_t* name, uint8_t len);
extern uint16_t ls_ble_set_manufac_data(uint8_t* p_data, uint8_t len);
extern uint16_t ls_ble_get_manufac_data(uint8_t* p_data, uint8_t len);

/*-----------------------------------------------------------------*/


#endif
